﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AddOrEditImage.aspx.cs" Inherits="admin_Modules_NewsEvent_Images_AddOrEditImage" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script src="/admin/resources/js/base.js" type="text/javascript"></script>
    <script src="/plugins/ckeditor/ckeditor.js" type="text/javascript"></script>
    <script src="/plugins/ckfinder/ckfinder.js" type="text/javascript"></script>
    <script src="/plugins/ckfinder/config.js" type="text/javascript"></script>
    <script language="javascript">
        function BrowseServer() {
            // You can use the "CKFinder" class to render CKFinder in a page:
            var finder = new CKFinder();
            finder.basePath = '/plugins/ckfinder/'; // The path for the installation of CKFinder (default = "/ckfinder/").
            finder.selectActionFunction = SetFileField;
            finder.popup();
        }


        // This is a sample function which is called when a file is selected in CKFinder.
        function SetFileField(fileUrl) {
            triggerAttachImage.setValue(fileUrl);
        }

        var confirmDelete = function () {
            Ext.Msg.confirm('Xác nhận', '<span style="color:red;">Xóa ảnh?</span>', function (btn) {
                if (btn == "yes") {
                    return true;
                }
            });
            return false;
        }

        function setCombo(value1) {
            if (value1 == 0) return;
            //            alert(value1);
            //            return;
            txtImageDetailCategory.setValue(value1);
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager runat="server" ID="SM">
    </ext:ResourceManager>
    <ext:Viewport ID="wdAddOrEditImageCategory" runat="server" Layout="BorderLayout">
        <Items>
            <ext:Panel Region="Center" BodyStyle="backgound-color:#fff;" BodyBorder="true" Layout="Fit">
                <TopBar>
                    <ext:Toolbar>
                        <Items>
                            <ext:Button Text="Tạo mới" Icon="Disk" ID="btnAdd" runat="server">
                                <DirectEvents>
                                    <Click OnEvent="AddOrUpdate" Before="valid = #{StatusForm2}.getForm().isValid(); if(valid){ Ext.Msg.wait('Đang cập nhật dữ liêu...', 'Saving'); } return valid;">
                                        <ExtraParams>
                                            <ext:Parameter Mode="Value" Name="mode" Value="add">
                                            </ext:Parameter>
                                        </ExtraParams>
                                    </Click>
                                </DirectEvents>
                            </ext:Button>
                            <ext:ToolbarSpacer>
                            </ext:ToolbarSpacer>
                            <ext:ToolbarSpacer>
                            </ext:ToolbarSpacer>
                            <ext:Button Text="Cập nhật" Icon="Disk" runat="server" ID="btnUpdateImage">
                                <DirectEvents>
                                    <Click OnEvent="AddOrUpdate" Before="valid = #{StatusForm2}.getForm().isValid(); if(valid){ Ext.Msg.wait('Đang cập nhật dữ liêu...', 'Saving'); } return valid;">
                                        <ExtraParams>
                                            <ext:Parameter Mode="Value" Name="mode" Value="edit">
                                            </ext:Parameter>
                                        </ExtraParams>
                                    </Click>
                                </DirectEvents>
                            </ext:Button>
                            <ext:ToolbarSpacer>
                            </ext:ToolbarSpacer>
                            <ext:ToolbarSpacer>
                            </ext:ToolbarSpacer>
                            <ext:ToolbarSpacer>
                            </ext:ToolbarSpacer>
                            <ext:ToolbarSpacer>
                            </ext:ToolbarSpacer>
                            <ext:Button Text="Xóa" Icon="Delete" ID="btnDeleteImage">
                                <DirectEvents>
                                    <Click OnEvent="AddOrUpdate" Before="valid =  confirmDelete(); return valid;">
                                        <ExtraParams>
                                            <ext:Parameter Mode="Value" Name="mode" Value="delete">
                                            </ext:Parameter>
                                        </ExtraParams>
                                    </Click>
                                </DirectEvents>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <Items>
                    <ext:FormPanel ID="StatusForm2" BodyBorder="false" Header="false" runat="server"
                        LabelWidth="120" BodyStyle="padding:5px">
                        <Items>
                            <ext:FormLayout>
                                <Anchors>
                                    <ext:Anchor Horizontal="95%">
                                        <ext:SelectBox ID="txtImageDetailCategory" runat="server" DisplayField="Name" ValueField="ID"
                                            AllowBlank="false" Width="200" EmptyText="Bấm vào chọn chuyên mục" FieldLabel="Chuyên mục">
                                            <Store>
                                                <ext:Store ID="storeProductCategory" runat="server">
                                                    <Reader>
                                                        <ext:JsonReader>
                                                            <Fields>
                                                                <ext:RecordField Name="Name" />
                                                                <ext:RecordField Name="ID" />
                                                            </Fields>
                                                        </ext:JsonReader>
                                                    </Reader>
                                                </ext:Store>
                                            </Store>
                                        </ext:SelectBox>
                                    </ext:Anchor>
                                    <ext:Anchor Horizontal="95%">
                                        <ext:TextField AllowBlank="false" ID="txtImageDetailTitle" runat="server" Width="200"
                                            EmptyText="Tiêu đề" FieldLabel="Tiêu đề">
                                        </ext:TextField>
                                    </ext:Anchor>
                                    <ext:Anchor Horizontal="95%">
                                        <ext:TextArea runat="server" ID="txtImageDetailDescription" Width="200" EmptyText="Mô tả"
                                            FieldLabel="Mô tả" Height="50">
                                        </ext:TextArea>
                                    </ext:Anchor>
                                    <ext:Anchor Horizontal="95%">
                                        <ext:NumberField ID="txtImageDetailOrder" Text="0" runat="server" FieldLabel="Thứ tự"
                                            EmptyText="Thứ tự">
                                        </ext:NumberField>
                                    </ext:Anchor>
                                    <ext:Anchor Horizontal="95%">
                                        <ext:TriggerField ID="triggerAttachImage" FieldLabel="Ảnh tỏm tắt" runat="server"
                                            EmptyText="Ảnh tóm tắt" AllowBlank="true" Editable="false">
                                            <Listeners>
                                                <TriggerClick Handler="BrowseServer();" />
                                                <Focus Handler="BrowseServer();" />
                                            </Listeners>
                                            <Triggers>
                                                <ext:FieldTrigger Icon="Ellipsis" />
                                            </Triggers>
                                        </ext:TriggerField>
                                    </ext:Anchor>
                                    <ext:Anchor Horizontal="95%">
                                        <ext:Checkbox runat="server" ID="chkActive" Checked="true" FieldLabel="Hiển thị">
                                        </ext:Checkbox>
                                    </ext:Anchor>
                                    <ext:Anchor Horizontal="95%">
                                        <ext:Checkbox ID="chkOntop" runat="server" Checked="true" FieldLabel="Hiển thị trang chủ">
                                        </ext:Checkbox>
                                    </ext:Anchor>
                                </Anchors>
                            </ext:FormLayout>
                        </Items>
                    </ext:FormPanel>
                </Items>
            </ext:Panel>
        </Items>
    </ext:Viewport>
    </form>
</body>
</html>
